package game;

import java.io.IOException;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

/**
 * Powerup (bomb range/strength upgrade)
 * @author Simon
 *
 */
public class Powerup implements ArenaObject {

	public static final int T_BOMB_RANGE = 1;
	public static final int T_BOMB_COUNT = 2;
	
	int tile_x, tile_y;
	int type;
	static Image image = null;
	Sprite gfx = null;
	boolean visible;
	boolean dead;
	
	public Powerup(int type, int tile_x, int tile_y) {
		visible = false;
		this.type = type;
		this.tile_x = tile_x;
		this.tile_y = tile_y;
		try {
			if (image == null) {
				image = Image.createImage("/gfx/boni.png");
			}
			gfx = new Sprite(image, 20, 20);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		switch (type) {
		case T_BOMB_RANGE: gfx.setFrame(0); break;
		case T_BOMB_COUNT: gfx.setFrame(1); break;
		}
		Arena.Position(gfx, tile_x, tile_y);
	}
	
	public void advance() {
	}

	public void draw(Graphics g) {
		if (visible) gfx.paint(g);
	}

	public boolean isDead() {
		return false;
	}

	public void setVisible(boolean visible) {
		this.visible = true;
	}
}
